﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Data;
using System.Collections.ObjectModel;
using saveimagetodatabase;

namespace WcfServiceLibrary2
{
    [DataContract]
  public  class SinhVienHoc:LopHoc
    {
       
        [DataMember]
        public int Id
        {
           get;set;
        }
       [DataMember]
        
        public string Hoten
        {
            get;set;
        }
       
        [DataMember]
        public int Malop
        {
           get;set;
        }
        
        
        
       
        public SinhVienHoc(DataRow row)
        
        {
            this.Id = row.IsNull("id") ? 0 : int.Parse(row["id"].ToString());
            this.Hoten = row.IsNull("hoten") ? string.Empty : row["hoten"].ToString();
            this.Malop = row.IsNull("malop") ? 0 : int.Parse(row["malop"].ToString());
            this.Tenlop = row.IsNull("tenlop") ? string.Empty : row["tenlop"].ToString();

        }
        public static ObservableCollection<SinhVienHoc> GetAllSinhVienHoc()
        {
            ObservableCollection<SinhVienHoc> list = new ObservableCollection<SinhVienHoc>();
            try
            {
                SqlQuery sql = new SqlQuery();
               DataTable data= sql.SelectAll("spGetAllLopHoc");
                foreach (DataRow row in data.Rows)
                {
                    SinhVienHoc sv = new SinhVienHoc(row);
                    list.Add(sv);

                }
                return list;
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
    }
}
